package com.javalong.affairs.module.renwujinzhang.activity.audit;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.EditText;

import com.javalong.affairs.R;
import com.javalong.affairs.base.common.ISynCallback;
import com.javalong.affairs.base.common.UIStatus;
import com.javalong.affairs.base.common.ViewHolder;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.constant.RequestKey;
import com.javalong.affairs.base.listener.BaseResponseListener;
import com.javalong.affairs.base.listener.DefaultResponseListener;
import com.javalong.affairs.base.model.User;
import com.javalong.affairs.base.utils.HttpUtils;
import com.javalong.affairs.base.utils.IntUtils;
import com.javalong.affairs.base.utils.StringUtils;
import com.javalong.affairs.base.utils.TimeUtils;
import com.javalong.affairs.base.utils.UrlUtils;
import com.javalong.affairs.module.renwujinzhang.activity.AuditoerActivity;
import com.javalong.affairs.module.renwujinzhang.activity.RecycleListActivity;
import com.javalong.affairs.module.renwujinzhang.activity.SupervisesActivity;
import com.javalong.affairs.module.renwujinzhang.activity.UpdateTaskActivity;
import com.javalong.affairs.module.renwujinzhang.activity.WatchRunTaskActivity;
import com.javalong.affairs.module.renwujinzhang.activity.suggest.activity.SuggestListActivity;
import com.javalong.affairs.module.renwujinzhang.model.Task;
import com.javalong.affairs.module.renwujinzhang.ui.SelectTimeView;
import com.javalong.affairs.module.renwujinzhang.ui.SelectUserView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 审核列表 详情
 */
public class WatchAuditTaskActivity extends WatchRunTaskActivity {

    public static void toThisActivity(Context context, Task task) {
        Intent intent = new Intent();
        intent.setClass(context, WatchAuditTaskActivity.class);
        intent.putExtra(BundleKey.TASK, task);
        context.startActivity(intent);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_task_watch_audit, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_audit_no:
                auditTask(0);
                break;
            case R.id.action_audit_ok:
                auditTask(1);
                break;
        }
        return true;
    }

    private void auditTask(int pass) {
        String url;
        if (pass == 0) {
            url = UrlUtils.getUrl("Task", "action_audit_disagree");
        } else {
            url = UrlUtils.getUrl("Task", "action_audit_agree");
        }
        Map<String, Object> param = new HashMap<>();
        param.put(RequestKey.ID, task.getRealId());
        HttpUtils.post(url, param, new DefaultResponseListener() {
            @Override
            public void onResponse(String jsonStr) {
                super.onResponse(jsonStr);
                finish();
            }
        });
    }
}
